// 品牌管理相关接口

import request from '@/utils/request.ts';
import type {
  TrademarkListReqData,
  TrademarkListResData,
  Trademark
} from './type.ts';
import { ResponseData } from '../type.ts';

enum API {
  TRADEMARK_GET_LIST = '/admin/product/baseTrademark',
  TRADEMARK_ADD = '/admin/product/baseTrademark/save',
  TRADEMARK_UPDATE = '/admin/product/baseTrademark/update',
  TRADEMARK_DELETE = '/admin/product/baseTrademark/remove'
}

// 获取品牌列表
export const reqTrademarkList = ({ page, limit }: TrademarkListReqData) =>
  request.get<any, TrademarkListResData>(
    API.TRADEMARK_GET_LIST + `/${page}/${limit}`
  );

// 提交品牌
export const reqAddOrUpdateTrademark = (params: Trademark) => {
  const method = params.id ? 'put' : 'post';
  const url = params.id ? API.TRADEMARK_UPDATE : API.TRADEMARK_ADD;
  return request[method]<any, ResponseData>(url, params);
};

// 删除品牌
export const reqDeleteTrademark = (id: number) =>
  request.delete<any, ResponseData>(API.TRADEMARK_DELETE + `/${id}`);
